home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / gs3.53 / stcolor.ps < prev    next >
Text File  |  1996-01-10  |  6KB  |  172 lines

  1. % Copyright (C) 1995 Aladdin Enterprises.  All rights reserved
  2. %
  3. % This file is part of Aladdin Ghostscript.
  4. %
  5. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6. % or distributor accepts any responsibility for the consequences of using it,
  7. % or for whether it serves any particular purpose or works at all, unless he
  8. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9. % License (the "License") for full details.
  10. %
  11. % Every copy of Aladdin Ghostscript must include a copy of the License,
  12. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  13. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14. % under certain conditions described in the License.  Among other things, the
  15. % License requires that the copyright notice and this notice be preserved on
  16. % all copies.
  17.  
  18. % stcolor.ps
  19. % Epson Stylus-Color Printer-Driver
  20.  
  21. % The purpose of this file is to configure the stcolor-printer driver
  22.  
  23. %
  24. % It is useless and dangerous to interpret the following code with anything
  25. % else than Ghostscript, so this condition is verified first. If this fails
  26. % a message is send to the output. If this message bothers you, remove it,
  27. % but I prefer to know why the device-setup failed.
  28.  
  29. statusdict begin product end
  30. dup (Ghostscript) eq exch (Aladdin Ghostscript) eq or{
  31.  
  32. % fetch the current device-parameters this is specific for Ghostscript.
  33.  
  34.   /STCold currentdevice getdeviceprops .dicttomark def
  35.  
  36. % Any Ghostscript-Driver has a Name, verify that the selected device is
  37. % stcolor, otherwise nothing than another message will be produced.
  38.  
  39.   STCold /Name get (stcolor) eq {
  40.  
  41. %
  42. % The main thing this file does, is to establish transfer-functions.
  43. % Here are two predefined arrays for 360x360Dpi and for 720x720DpI.
  44. % If resolution is 360x720 or 720x360 the average is used. You may
  45. % want to define other arrays here.
  46. %
  47.  
  48.      /STCdeftransfer [ 0.0 1.0 ] def
  49.  
  50.      /STCKtransfer360 [
  51.        0.0000 0.0034 0.0185 0.0377 0.0574 0.0769 0.0952 0.1147
  52.        0.1337 0.1540 0.1759 0.1985 0.2209 0.2457 0.2706 0.2949
  53.        0.3209 0.3496 0.3820 0.4145 0.4505 0.4907 0.5344 0.5840
  54.        0.6445 0.7093 0.8154 0.9816 0.9983 0.9988 0.9994 1.0000
  55.      ] def
  56.  
  57.      /STCKtransfer720 [
  58.        0.0000 0.0011 0.0079 0.0151 0.0217 0.0287 0.0354 0.0425
  59.        0.0492 0.0562 0.0633 0.0700 0.0766 0.0835 0.0900 0.0975
  60.        0.1054 0.1147 0.1243 0.1364 0.1489 0.1641 0.1833 0.2012
  61.        0.2217 0.2492 0.2814 0.3139 0.3487 0.3996 0.4527 0.5195
  62.      ] def
  63.  
  64. % compute the resolution
  65.  
  66.      STCold /HWResolution get dup
  67.      0 get exch 1 get mul sqrt /STCdpi exch def
  68.  
  69. % pick the colormodel
  70.      STCold /ProcessColorModel get /STCcolor exch def
  71.  
  72.  
  73.      mark % prepare stack for "putdeviceprops" 
  74.  
  75. % warn for BitsPerPixel=30 with fsrgb
  76.      STCcolor /DeviceRGB eq STCold /BitsPerPixel get 32 eq and 
  77.      {
  78.        (%%[ stcolor.ps: inefficient RGB-setup, recommend BitsPerPixel=24 ]%%\n)
  79.        print
  80.       } if
  81.  
  82. % if the Dithering-Method is default (gscmyk), change it to fscmyk
  83. % this is achieved by pushing a name/value-pair onto the stack
  84. % if the selected algorithm uses another ProcessColorModel, it is necessary
  85. % to change the Value of STCcolor according to the new algorithm.
  86.  
  87.      STCold /Dithering get (gscmyk) eq 
  88.      { 
  89.         /Dithering (hscmyk) % preferred dithering-method
  90.      } if % might be necessary to change STCcolor too
  91.  
  92. %
  93. % select the array according to the resolution
  94. %
  95.      STCdpi 359.0 lt 
  96.      { STCdeftransfer }
  97.      { STCdpi 361.0 lt
  98.        { STCKtransfer360 }
  99.        { STCdpi 719.0 gt
  100.          { STCKtransfer720 }
  101.          {
  102.            STCKtransfer360 length STCKtransfer720 length eq
  103.            {
  104.              0 1 STCKtransfer360 length 1 sub 
  105.              {
  106.                dup dup 
  107.                STCKtransfer360 exch get 
  108.                exch STCKtransfer720 exch get 
  109.                add 2.0 div 
  110.                STCKtransfer360 3 1 roll put
  111.              } for
  112.            }if
  113.            STCKtransfer360
  114.          } ifelse
  115.        }ifelse
  116.      } ifelse
  117.      /STCtransfer exch def
  118.  
  119. %
  120. % Add the arrays. With Version 1.17 and above, it seems to be 
  121. % a good idea, to use the transfer-arrays as coding-arrays too.
  122. %
  123.  
  124. %
  125. % RGB-Model requires inversion of the transfer-arrays
  126. %
  127.      STCcolor /DeviceRGB eq 
  128.      {
  129.         /RGBtransfer STCtransfer length array def
  130.         0 1 STCtransfer length 1 sub
  131.         {
  132.           dup RGBtransfer length 1 sub exch sub exch 
  133.           STCtransfer exch get 1.0 exch sub
  134.           RGBtransfer 3 1 roll put
  135.         } for
  136.  
  137.         /Rtransfer RGBtransfer
  138.         /Gtransfer RGBtransfer
  139.         /Btransfer RGBtransfer
  140.  
  141.         /Rcoding   RGBtransfer
  142.         /Gcoding   RGBtransfer
  143.         /Bcoding   RGBtransfer
  144.  
  145.      }{
  146.  
  147.        /Ctransfer STCtransfer
  148.        /Mtransfer STCtransfer
  149.        /Ytransfer STCtransfer
  150.        /Ktransfer STCtransfer
  151.  
  152.        /Ccoding   STCtransfer
  153.        /Mcoding   STCtransfer
  154.        /Ycoding   STCtransfer
  155.        /Kcoding   STCtransfer
  156.  
  157.      } ifelse
  158.  
  159.      counttomark 0 ne 
  160.         {currentdevice putdeviceprops pop}{cleartomark}ifelse
  161.  
  162. % decativate predefined correction
  163.  
  164.      {} dup dup currenttransfer setcolortransfer
  165.  
  166.   }{
  167.     (%%[ stcolor.ps: currentdevice is not stcolor - ignored ]%%\n) print
  168.   } ifelse
  169. }{
  170.   (%%[ stcolor.ps: interpreted not by Aladdin Ghostscript - ignored ]%%\n) print
  171. } ifelse
  172.